package visualization;

import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;

import model.OligoSystemGeneral;

import org.apache.commons.collections15.Transformer;

public class MyVertexTransformer<String, Shape> implements Transformer<String, Shape> {
	
	double r = 10;
	int C = 0;
	double A = 250*250;
	double K;
	ArrayList<Double> r0 = new ArrayList<Double>();
	double[][] TimeSerie;
	OligoSystemGeneral oligo;
	
	public MyVertexTransformer(double[][]TimeSerie, OligoSystemGeneral oligo) {
		this.TimeSerie = TimeSerie;
		this.oligo = oligo;
		K = Math.pow(1.5*1.5*A/oligo.nameToInt.size(), 0.5);
	}

	@Override
	public Shape transform(String i){
	//System.err.println( i + " : " +  fight[nameToInt.get(i)][250] );
	if(oligo.t2 == 0){
	for(int j = 0; j < oligo.nameToInt.size(); j++){
		r0.add(10.0);
	//						double M = 0.0;
	//						if(fight != null){
	//							for(int t1 = 0; t1 < 500; t1++){
	//								M += fight[j][t1];
	//							}
	//							M = M / 500;
	//						}
	//						Moy.add(M);
	}
	oligo.t2 = 1;
	}
	r = r0.get(oligo.nameToInt.get(i));
	if(TimeSerie != null){
	r = 8 + Math.log(1 + 30 * TimeSerie[oligo.nameToInt.get(i)][oligo.t] / K) * 5;
	C++;
	oligo.t2 = 1;
	if(C == oligo.nameToInt.size()){
		C = 0;
		oligo.t++;
	}
	}
	r0.set(oligo.nameToInt.get(i), r);
	if(oligo.t > 500)
		oligo.t = 0;
	
	Shape style = (Shape) new Ellipse2D.Double(-r,-r,2*r,2*r);
	
	return(style);
	}

}
